package login;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
/**
 * Sets up connection to database-
 * for login, creating new user at registration, seeds, etc.
 * @author Ben
 */
public class ConnectionManager 
{ 
	static Connection conn;
		
        /**
        * Static method that starts up connection to database
        * 
        * @return Connection object with the database
        */
	public static Connection getConnection()
	{ 
		try 
		{
			String url = "jdbc:mysql://localhost:3306/";
			String dbName ="cs2340seedswap";
			String uname = "root";
			String pwd = "pass";
			
			Class.forName("com.mysql.jdbc.Driver");
			try 
			{
				conn = DriverManager.getConnection(url+dbName,uname,pwd); 
			}
			catch (SQLException ex)
			{
				ex.printStackTrace(); 
			} 
		} 
		catch(ClassNotFoundException e)
		{
			System.out.println(e); 
		} 
		return conn; 
	}

}
